package o;

import android.content.Context;
import java.lang.reflect.InvocationTargetException;
import java.lang.reflect.Method;

public class edt {
    private static final byte[] ˋ = new byte[0];
    private static edt ˎ;
    private Class<?> ˊ = ˎ();
    private Method ˏ;
    private Object ॱ;
    private boolean ᐝ;

    public static edt ॱ() {
        edt o_edt;
        synchronized (ˋ) {
            if (ˎ == null) {
                ˎ = new edt();
            }
            o_edt = ˎ;
        }
        return o_edt;
    }

    private edt() {
        if (this.ˊ != null) {
            this.ॱ = ˏ();
            if (this.ॱ != null) {
                this.ˏ = ˋ();
                if (this.ˏ != null) {
                    this.ᐝ = true;
                }
            }
        }
    }

    private Object ˏ() {
        Object obj = null;
        try {
            obj = this.ˊ.getDeclaredMethod("getInstance", new Class[0]).invoke(null, new Object[0]);
        } catch (NoSuchMethodException e) {
            Logger.ˎ("PowerManagerUtils", "NoSuchMethodException getInstance method");
        } catch (IllegalAccessException e2) {
            Logger.ˎ("PowerManagerUtils", "IllegalAccessException getInstance method");
        } catch (InvocationTargetException e3) {
            Logger.ˎ("PowerManagerUtils", "InvocationTargetException getInstance method");
        } catch (Exception e4) {
            Logger.ˎ("PowerManagerUtils", "getInstance method" + e4.getMessage());
        }
        return obj;
    }

    private static Class<?> ˎ() {
        Class<?> cls = null;
        try {
            cls = Class.forName("com.huawei.pgmng.plug.PGSdk");
        } catch (ClassNotFoundException e) {
            Logger.ˏ("PowerManagerUtils", "ClassNotFoundException" + e.toString());
        } catch (ExceptionInInitializerError e2) {
            Logger.ˏ("PowerManagerUtils", "class not found, e is: " + e2.toString());
        } catch (LinkageError e3) {
            Logger.ˏ("PowerManagerUtils", "class not found, e is: " + e3.toString());
        }
        if (cls == null) {
            try {
                cls = Class.forName("com.huawei.android.pgmng.plug.PowerKit");
                Logger.ˏ("PowerManagerUtils", "use new thermalInfo");
            } catch (ClassNotFoundException e4) {
                Logger.ˏ("PowerManagerUtils", "ClassNotFoundException" + e4.toString());
            } catch (ExceptionInInitializerError e22) {
                Logger.ˏ("PowerManagerUtils", "class not found, e is: " + e22.toString());
            } catch (LinkageError e32) {
                Logger.ˏ("PowerManagerUtils", "class not found, e is: " + e32.toString());
            }
        } else {
            Logger.ˏ("PowerManagerUtils", "use old thermalInfo");
        }
        if (cls == null) {
            Logger.ˎ("PowerManagerUtils", "can not found power manager interface");
        }
        return cls;
    }

    private Method ˋ() {
        Method method = null;
        try {
            method = this.ˊ.getMethod("getThermalInfo", new Class[]{Context.class, Integer.TYPE});
        } catch (NoSuchMethodException e) {
            Logger.ˎ("PowerManagerUtils", "can not found getThermalInfo method");
        }
        return method;
    }

    public int ˋ(Context context, int i) {
        if (this.ᐝ) {
            try {
                Object invoke = this.ˏ.invoke(this.ॱ, new Object[]{context, Integer.valueOf(i)});
                if (invoke instanceof Integer) {
                    return ((Integer) invoke).intValue();
                }
            } catch (IllegalAccessException e) {
                Logger.ˎ("PowerManagerUtils", "IllegalAccessException");
            } catch (InvocationTargetException e2) {
                Logger.ˎ("PowerManagerUtils", "InvocationTargetException");
            } catch (Exception e3) {
                Logger.ˎ("PowerManagerUtils", "InvocationTargetException");
            }
        }
        return -1;
    }
}
